var { appUtils, gUtils } = require("../shizukuUtils/index");

function main(appName, type) {
  if ($shizuku.isRunning()) {
    var closeRecent = true;
    var closeAll = false;
    if (type == 1) {
      closeRecent = false;
      closeAll = false;
    }
    if (type == 2) {
      closeRecent = false;
      closeAll = true;
    }
    if (closeRecent) {
      appUtils.closeRecent();
    }
    if (closeAll) {
      appUtils.closeAll();
    }
    if (appName) {
      gUtils.sleep(2, 3);
      appUtils.openApp(appName);
    }
  } else {
    console.show();
    console.log("shizuku 未运行，请检查");
  }
}
Wang.main = main;
